﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Data_Access_Layer;
using Model_Layer;

namespace Business_Logic_Layer
{
    public class BLLAirport
    {
        private static IDBAirport dbAirport = new DBAirport();
        private static IDBAirport dbAirportObj = new DBAirport();


        public Airport GetSelectedAirport(int idairport)
        {
            try
            {
                return dbAirport.getSelectedAirport(idairport);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

        public List<Airport> GetAllAirports()
        {
            try { return dbAirport.GetAllAirports(); }
            catch(Exception ex){ throw new Exception(ex.Message); }
        }

        public List<Airport> searchAllAirports(string search) 
        {
            try 
            { 
                return dbAirport.searchAllAirports(search); 
            }
            catch(Exception ex) { throw new Exception(ex.Message); }
        }

        public List<int> GetAdjIdAirportList(int idairport)
        {
            try
            {
                return dbAirportObj.GetIdAdjacentcyList(idairport);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

        public List<Airport> GetAdjAirportList(int idairport)
        {
            try 
            {  
                List<int> airportAdjList = new List<int>();
                airportAdjList = dbAirportObj.GetIdAdjacentcyList(idairport);
                return dbAirport.GetAdjacentcyList(airportAdjList); 
            }
            catch(Exception ex){ throw new Exception(ex.Message); }
        }
    }
}
